<div id="content">
    <div smart-include="sensor/views/sub-header.tpl.html"></div>
    <div class="clearfix margin-bottom-10">
        <div class="pull-left">
            <a class="btn btn-labeled btn-primary" data-toggle="modal" ng-click="addbox()">
                <span class="btn-label"><i class="glyphicon glyphicon-plus"></i></span>
                添加用户
            </a>
        </div>
        <div class="pull-left margin-left-10">
            <strong class="font-md" style="vertical-align: middle;">账号：</strong>
            <label class="input">
                <input type="text"  ng-model="searchid" class="form-control" placeholder="账号">
            </label>
            <a class="btn btn-primary" ng-click="get_user()">查询</a>
        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-bordered table-hover no-margin font-sml table-striped sensor_table">
            <thead>
            <tr>
                <th>操作</th>
                <th class="text-align-center">账号</th>
                <th class="text-align-center">用户名称</th>
                <th class="text-align-center">角色</th>
                <th class="text-align-center">微信openid</th>
                <th class="text-align-center">电话</th>
                <th class="text-align-center">报警等级</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="data in datas">
                <td>
                    <button class='btn btn-xs btn-default' uib-tooltip='编辑' tooltip-append-to-body='true' data-toggle="modal" data-target="#editAlert" ng-click="showEditAlert(data)"><i class='fa fa-pencil'></i></button>
                    <button class='btn btn-xs btn-default' uib-tooltip='删除' tooltip-append-to-body='true'data-toggle="modal" data-target="#delAlert" ng-click="showDelDialog(data.id)"><i class='fa fa-times'></i></button>
                </td>
                <td class="text-align-center">{{data.id}}</td>
                <td class="text-align-center">{{data.name}}</td>
                <td class="text-align-center" ng-switch="{{data.roleid}}">
                        <span ng-switch-when="0">
                            无
                        </span>
                    <span ng-switch-default>
                            {{data.rolename}}
                        </span>
                </td>
                <td class="text-align-center">{{data.wx_openid}}</td>
                <td class="text-align-center">{{data.tele}}</td>
                <td class="text-align-center" ng-switch="{{data.warn_grade}}">
                        <span ng-switch-when="-1">
                            无
                        </span>
                    <span ng-switch-default>
                            {{data.warn_grade}}
                        </span>
                </td>
            </tr>

            </tbody>
        </table>
    </div>

    <!-- end widget content -->
    <div class="dt-toolbar-footer">
        <tm-pagination conf="paginationConf"></tm-pagination>
    </div>

    <div class="modal fade" id="addAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">添加用户</h4>
                </div>
                <div class="modal-body">
                    <form  class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">账号</label>
                            <div class="col-sm-9">
                                <input type="text" ng-model="addobj.id" class="form-control" placeholder="账号">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">用户名称</label>
                            <div class="col-sm-9">
                                <input type="text"  ng-model="addobj.name" class="form-control" placeholder="用户名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">微信openid</label>
                            <div class="col-sm-9">
                                <input type="text"  ng-model="addobj.wx_openid" class="form-control" placeholder="微信号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">角色</label>
                            <div class="col-sm-9">
                                <select ng-model="addobj.roleid" class="form-control">
                                    <option value="0">无</option>
                                    <option value="{{role.id}}" ng-repeat = "role in roles">{{role.name}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">报警等级</label>
                            <div class="col-sm-9">
                                <select ng-model="addobj.warn_grade" class="form-control">
                                    <option value="-1">无</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">电话</label>
                            <div class="col-sm-9">
                                <input type="text" ng-model="addobj.tele" class="form-control"placeholder="电话">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default"data-dismiss="modal">关闭</button>
                    <button class="btn btn-primary" ng-click="sure_add()">提交</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade in" id="editAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">编辑用户</h4>
                </div>
                <div class="modal-body">
                    <form  class="form-horizontal">
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">账号</label>
                            <div class="col-sm-9">
                                <input type="text" readonly="true" ng-model="editobj.id" class="form-control"placeholder="账号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">用户名称</label>
                            <div class="col-sm-9">
                                <input type="text" ng-model="editobj.name" class="form-control" placeholder="用户名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">微信openid</label>
                            <div class="col-sm-9">
                                <input type="text" ng-model="editobj.wx_openid" class="form-control" placeholder="微信号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">角色</label>
                            <div class="col-sm-9">
                                <select ng-model="editobj.roleid" class="form-control">
                                    <option value="0" >无</option>
                                    <option value="{{role.id}}" ng-repeat = "role in roles">{{role.name}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="firstname" class="col-sm-2 control-label">报警等级</label>
                            <div class="col-sm-9">
                                <select ng-model="editobj.warn_grade" class="form-control">
                                    <option value="-1">无</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">电话</label>
                            <div class="col-sm-9">
                                <input type="text" ng-model="editobj.tele" class="form-control"placeholder="电话">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default"data-dismiss="modal">关闭</button>
                    <button class="btn btn-primary" ng-click="sure_edit()">提交</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade in" id="delAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title">信息</h4>
                </div>
                <div class="modal-body">
                    <p>
                        您确实要删除这个用户吗？
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" ng-click="sure_del()">
                        确认
                    </button>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
    <!-- /.modal-dialog -->
</div>
<!-- END MAIN CONTENT -->
<script>
    //点击任意地方隐藏弹出框
    //  $(document).click(function(){
    //     $(".header_box_role").hide();
    //     $(".header_box").hide();
    // });
    // <div class="popover top in header_box_role{{data.roleid}} header_box_role">
    //     <div class="arrow"></div>
    //     <div class="popover-content">
    //         <div>
    //             <form class="form-inline">
    //                 <div>
    //                     <div class="editable-input">
    //                         <select class="input-sm" ng-modal="currentTeam" class="sele_team">
    //                             <option ng-repeat="team in teams" value="{{team.id}}">
    //                                 {{team.name}}
    //                             </option>
    //                         </select>
    //                     </div>
    //                     <div class="editable-buttons">
    //                         <button type="submit" class="btn btn-primary btn-sm" ng-click="btn_determine_team()">
    //                             <i class="glyphicon glyphicon-ok"></i>
    //                         </button>
    //                         <button type="button" class="btn btn-default btn-sm" id="btn_del_team">
    //                             <i class="glyphicon glyphicon-remove"></i>
    //                         </button>
    //                     </div>
    //                 </div>
    //             </form>
    //         </div>
    //     </div>
    // </div>
</script>